{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "18042330",
   "metadata": {},
   "source": [
    "> 时间： 2022/10/18-week09\n",
    "-----"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "814a2de6",
   "metadata": {},
   "source": [
    "#  本周知识点\n",
    "> 1.while循环  \n",
    "> 2.购物车的练习   \n",
    "> 3.元组_集合"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "9a77f1a5",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "你是风儿我是沙，哈哈哈哈哈哈哈 0\n",
      "你是风儿我是沙，哈哈哈哈哈哈哈 1\n",
      "你是风儿我是沙，哈哈哈哈哈哈哈 2\n",
      "你是风儿我是沙，哈哈哈哈哈哈哈 3\n",
      "你是风儿我是沙，哈哈哈哈哈哈哈 4\n",
      "你是风儿我是沙，哈哈哈哈哈哈哈 5\n",
      "你是风儿我是沙，哈哈哈哈哈哈哈 6\n",
      "你是风儿我是沙，哈哈哈哈哈哈哈 7\n",
      "你是风儿我是沙，哈哈哈哈哈哈哈 8\n",
      "你是风儿我是沙，哈哈哈哈哈哈哈 9\n",
      "你是风儿我是沙，哈哈哈哈哈哈哈 10\n",
      "你是风儿我是沙，哈哈哈哈哈哈哈 11\n",
      "你是风儿我是沙，哈哈哈哈哈哈哈 12\n",
      "你是风儿我是沙，哈哈哈哈哈哈哈 13\n",
      "你是风儿我是沙，哈哈哈哈哈哈哈 14\n",
      "你是风儿我是沙，哈哈哈哈哈哈哈 15\n",
      "你是风儿我是沙，哈哈哈哈哈哈哈 16\n",
      "你是风儿我是沙，哈哈哈哈哈哈哈 17\n",
      "你是风儿我是沙，哈哈哈哈哈哈哈 18\n",
      "你是风儿我是沙，哈哈哈哈哈哈哈 19\n",
      "你是风儿我是沙，哈哈哈哈哈哈哈 20\n",
      "你是风儿我是沙，哈哈哈哈哈哈哈 21\n",
      "你是风儿我是沙，哈哈哈哈哈哈哈 22\n",
      "你是风儿我是沙，哈哈哈哈哈哈哈 23\n",
      "你是风儿我是沙，哈哈哈哈哈哈哈 24\n",
      "你是风儿我是沙，哈哈哈哈哈哈哈 25\n",
      "你是风儿我是沙，哈哈哈哈哈哈哈 26\n",
      "你是风儿我是沙，哈哈哈哈哈哈哈 27\n",
      "你是风儿我是沙，哈哈哈哈哈哈哈 28\n",
      "你是风儿我是沙，哈哈哈哈哈哈哈 29\n",
      "你是风儿我是沙，哈哈哈哈哈哈哈 30\n",
      "你是风儿我是沙，哈哈哈哈哈哈哈 31\n",
      "你是风儿我是沙，哈哈哈哈哈哈哈 32\n",
      "你是风儿我是沙，哈哈哈哈哈哈哈 33\n",
      "你是风儿我是沙，哈哈哈哈哈哈哈 34\n",
      "你是风儿我是沙，哈哈哈哈哈哈哈 35\n",
      "你是风儿我是沙，哈哈哈哈哈哈哈 36\n",
      "你是风儿我是沙，哈哈哈哈哈哈哈 37\n",
      "你是风儿我是沙，哈哈哈哈哈哈哈 38\n",
      "你是风儿我是沙，哈哈哈哈哈哈哈 39\n",
      "你是风儿我是沙，哈哈哈哈哈哈哈 40\n",
      "你是风儿我是沙，哈哈哈哈哈哈哈 41\n",
      "你是风儿我是沙，哈哈哈哈哈哈哈 42\n",
      "你是风儿我是沙，哈哈哈哈哈哈哈 43\n",
      "你是风儿我是沙，哈哈哈哈哈哈哈 44\n",
      "你是风儿我是沙，哈哈哈哈哈哈哈 45\n",
      "你是风儿我是沙，哈哈哈哈哈哈哈 46\n",
      "你是风儿我是沙，哈哈哈哈哈哈哈 47\n",
      "你是风儿我是沙，哈哈哈哈哈哈哈 48\n",
      "你是风儿我是沙，哈哈哈哈哈哈哈 49\n",
      "你是风儿我是沙，哈哈哈哈哈哈哈 50\n",
      "你是风儿我是沙，哈哈哈哈哈哈哈 51\n",
      "你是风儿我是沙，哈哈哈哈哈哈哈 52\n",
      "你是风儿我是沙，哈哈哈哈哈哈哈 53\n",
      "你是风儿我是沙，哈哈哈哈哈哈哈 54\n",
      "你是风儿我是沙，哈哈哈哈哈哈哈 55\n",
      "你是风儿我是沙，哈哈哈哈哈哈哈 56\n",
      "你是风儿我是沙，哈哈哈哈哈哈哈 57\n",
      "你是风儿我是沙，哈哈哈哈哈哈哈 58\n",
      "你是风儿我是沙，哈哈哈哈哈哈哈 59\n",
      "你是风儿我是沙，哈哈哈哈哈哈哈 60\n",
      "你是风儿我是沙，哈哈哈哈哈哈哈 61\n",
      "你是风儿我是沙，哈哈哈哈哈哈哈 62\n",
      "你是风儿我是沙，哈哈哈哈哈哈哈 63\n",
      "你是风儿我是沙，哈哈哈哈哈哈哈 64\n",
      "你是风儿我是沙，哈哈哈哈哈哈哈 65\n",
      "你是风儿我是沙，哈哈哈哈哈哈哈 66\n",
      "你是风儿我是沙，哈哈哈哈哈哈哈 67\n",
      "你是风儿我是沙，哈哈哈哈哈哈哈 68\n",
      "你是风儿我是沙，哈哈哈哈哈哈哈 69\n",
      "你是风儿我是沙，哈哈哈哈哈哈哈 70\n",
      "你是风儿我是沙，哈哈哈哈哈哈哈 71\n",
      "你是风儿我是沙，哈哈哈哈哈哈哈 72\n",
      "你是风儿我是沙，哈哈哈哈哈哈哈 73\n",
      "你是风儿我是沙，哈哈哈哈哈哈哈 74\n",
      "你是风儿我是沙，哈哈哈哈哈哈哈 75\n",
      "你是风儿我是沙，哈哈哈哈哈哈哈 76\n",
      "你是风儿我是沙，哈哈哈哈哈哈哈 77\n",
      "你是风儿我是沙，哈哈哈哈哈哈哈 78\n",
      "你是风儿我是沙，哈哈哈哈哈哈哈 79\n",
      "你是风儿我是沙，哈哈哈哈哈哈哈 80\n",
      "你是风儿我是沙，哈哈哈哈哈哈哈 81\n",
      "你是风儿我是沙，哈哈哈哈哈哈哈 82\n",
      "你是风儿我是沙，哈哈哈哈哈哈哈 83\n",
      "你是风儿我是沙，哈哈哈哈哈哈哈 84\n",
      "你是风儿我是沙，哈哈哈哈哈哈哈 85\n",
      "你是风儿我是沙，哈哈哈哈哈哈哈 86\n",
      "你是风儿我是沙，哈哈哈哈哈哈哈 87\n",
      "你是风儿我是沙，哈哈哈哈哈哈哈 88\n",
      "你是风儿我是沙，哈哈哈哈哈哈哈 89\n",
      "你是风儿我是沙，哈哈哈哈哈哈哈 90\n",
      "你是风儿我是沙，哈哈哈哈哈哈哈 91\n",
      "你是风儿我是沙，哈哈哈哈哈哈哈 92\n",
      "你是风儿我是沙，哈哈哈哈哈哈哈 93\n",
      "你是风儿我是沙，哈哈哈哈哈哈哈 94\n",
      "你是风儿我是沙，哈哈哈哈哈哈哈 95\n",
      "你是风儿我是沙，哈哈哈哈哈哈哈 96\n",
      "你是风儿我是沙，哈哈哈哈哈哈哈 97\n",
      "你是风儿我是沙，哈哈哈哈哈哈哈 98\n",
      "你是风儿我是沙，哈哈哈哈哈哈哈 99\n"
     ]
    }
   ],
   "source": [
    "# while True 可以实现for + range 的方法\n",
    "# while True 一般用于不确定的循环次数或者无限次循环操作\n",
    "count = 0\n",
    "while True:\n",
    "    print(\"你是风儿我是沙，哈哈哈哈哈哈哈\",count)\n",
    "    count +=1\n",
    "    if count == 100:\n",
    "        break"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "bd443174",
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "hide_card:········\n",
      "游戏开始\n",
      "guess_digit:40\n",
      "往小了想想。\n",
      "guess_digit:30\n",
      "往大了猜\n",
      "guess_digit:33\n",
      "往小了想想。\n",
      "guess_digit:32\n",
      "yes ,you got it.\n"
     ]
    }
   ],
   "source": [
    "import getpass\n",
    "hide_card = int(getpass.getpass(\"hide_card:\"))\n",
    "count = 0 \n",
    "# print(hide_card)\n",
    "if hide_card <100 and hide_card>0:\n",
    "    print(\"游戏开始\")\n",
    "    while True:\n",
    "        if count <5:\n",
    "            guess_digit = int(input(\"guess_digit:\")) #玩游戏的人\n",
    "            if guess_digit == hide_card:\n",
    "                print(\"yes ,you got it.\")\n",
    "                break\n",
    "            elif guess_digit > hide_card:\n",
    "                print(\"往小了想想。\")\n",
    "            else:\n",
    "                print(\"往大了猜\")\n",
    "            count = count+1\n",
    "        else:\n",
    "            print(\"猜这么多次都不对，你个笨蛋！\")\n",
    "            print(\"正确答案是：%s\"%hide_card)\n",
    "            break\n",
    "else:\n",
    "    print(\"请输入数字在0-99之间。不要耍赖！\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "282de120",
   "metadata": {},
   "source": [
    "## 购物车\n",
    " > 购物车程序项目"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "dea52f5b",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 1.运行程序后，让用户输入支付宝余额√，然后打印我们的商品列表给用户\n",
    "good_list = [\n",
    "    [\"蜜桃四季春\",6],\n",
    "    [\"柠檬四季春\",4],\n",
    "    [\"草莓波波奶盖\",10],\n",
    "    [\"杨枝甘露\",12],\n",
    "]\n",
    "AliPay = int(input(\"请输入余额：\"))\n",
    "print(\"------------------------------------------蜜雪冰城---------------------------------------------------\")\n",
    "for i in range(4):\n",
    "    print(i,good_list[i][0],str(good_list[i][1])+\"元\")\n",
    "    \n",
    "# 2.让用户输入商品编号√，进行商品的购买√\n",
    "user_choice = int(input(\"请输入商品编号：\"))\n",
    "# 3 用户选择商品后，检查用户的余额是否够√，若够则直接扣款√，不够则提醒用户\n",
    "\n",
    "if AliPay > good_list[use_choice][1]:+"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "9a99f4e3",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "请输入余额：1000\n",
      "-------------------------------------食品列单---------------------------------\n",
      "杨枝甘露 16\n",
      "草莓脆脆 10\n",
      "蜜桃四季春 8\n",
      "蜜雪大红袍 6\n"
     ]
    }
   ],
   "source": [
    "# 运行程序后，让用户输入余额，然后打印我们的商品列表给客户\n",
    "good_list = [\n",
    "    [\"杨枝甘露\",16],\n",
    "    [\"草莓脆脆\",10],\n",
    "    [\"蜜桃四季春\",8],\n",
    "    [\"蜜雪大红袍\",6],\n",
    "]\n",
    "AliPay = int(input(\"请输入余额：\"))\n",
    "print(\"-------------------------------------食品列单---------------------------------\")\n",
    "for i in range(4):\n",
    "    print(good_list[i][0],good_list[i][1])\n",
    "    "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "ae2c7105",
   "metadata": {},
   "outputs": [
    {
     "ename": "IndentationError",
     "evalue": "unexpected indent (592725281.py, line 10)",
     "output_type": "error",
     "traceback": [
      "\u001b[1;36m  Input \u001b[1;32mIn [8]\u001b[1;36m\u001b[0m\n\u001b[1;33m    for i in range(4):\u001b[0m\n\u001b[1;37m    ^\u001b[0m\n\u001b[1;31mIndentationError\u001b[0m\u001b[1;31m:\u001b[0m unexpected indent\n"
     ]
    }
   ],
   "source": [
    "# 运行程序后，让用户输入余额，然后打印我们的商品列表给客户\n",
    "good_list = [\n",
    "    [\"杨枝甘露\",16],\n",
    "    [\"草莓脆脆\",10],\n",
    "    [\"蜜桃四季春\",8],\n",
    "    [\"蜜雪大红袍\",6],\n",
    "]\n",
    "AliPay = int(input(\"请输入余额：\"))\n",
    "print(\"-------------------------------------食品列单---------------------------------\")\n",
    "    Sfor i in range(4):\n",
    "        print(good_list[i][0],good_list[i][1]+\"元\")\n",
    "    # 2 让用户输入商品编号√，进行商品的购买√\n",
    "    user_choice = input(\"请输入商品编号：\")\n",
    "    # 3 用户选择商品后，检查用户的余额是否够√，若够则直接扣款√，不够则提醒用户√\n",
    "    # 2.1 用户输入商品序号（数值）\n",
    "    if user_choice.isdight():\n",
    "        user_choice = int(user_choice)\n",
    "        if AliPay > good_list[user_choice][1]:\n",
    "            # 余额足够\n",
    "            AliPay = AliPay - good_list[user_choice][1] # 更新用户余额\n",
    "            shopping_list.append(good_list[user_choice])\n",
    "            print(\"购买成功，请等待制作......您的余额还有：%s元\"%(AliPay))\n",
    "        else:\n",
    "            # 余额足够\n",
    "            AliPay = AliPay - good_list[user_choice][1] # 更新用户余额\n",
    "            shopping_list.append(good_list[user_choice])\n",
    "            print(\"购买成功，请等待制作...您的余额还有：%s元\"%(AliPay))\n",
    "        else:\n",
    "            #余额不够\n",
    "            print(\"您的余额不足\"+str(good_list[user_choice][1])+\"元，请更换支付方式或者选择其他商品，欢迎再来尝试\")\n",
    "        # 3.2 用户输入其他\n",
    "    elif user_choice == \"q\":\n",
    "        print(\"感谢您的购买，欢迎下次光临\")\n",
    "        print(\"您的购物车：\",shopping_list)\n",
    "        print(\"您的余额还有：\",AliPay)\n",
    "        break\n",
    "    else:\n",
    "        print(\"您输入的商品不存在或者您输入的内容有误\")\n",
    "    "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "589ed6ac",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.12"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
